package com.lzy.conf;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;

/**
 * 国际化
 */
@Slf4j
@Service
public class I18nServiceImpl implements I18nService {
    private MessageSource messageSource;

    @Autowired
    public I18nServiceImpl(MessageSource messageSource) {
        this.messageSource = messageSource;
    }

    @Override
    public String getMessage(String key) {
        return messageSource.getMessage(key, new String[0], LocaleContextHolder.getLocale());
    }
}
